package oop.core.visitors;

import oop.core.RunGame;
import oop.core.entity.DerivedStats;
import oop.core.entity.Occupation;
import oop.core.item.*;
import oop.core.map.*;

import java.util.*;

/**
 * TrapItem implements InteractiveItem
 * Items that are interactive on the map
 * and can injure an avatar
 *
 */
public class InteractiveItemVisitor
{
	private Occupation occupation;
	private DerivedStats derivedStats;
	private Inventory inventory;
	private Location desiredLocation;
	private Map<Location, InteractiveItemVisitable> map;

	public InteractiveItemVisitor(Occupation occupation, DerivedStats derivedStats, Inventory inventory, 
			Location loc, Map<Location, InteractiveItemVisitable> map){
		this.occupation = occupation;
		this.derivedStats = derivedStats;
		this.inventory = inventory;
		this.map = map;
		this.desiredLocation = loc;
	}

	public void visitNonTrap(NonTrapItem item){
		item.activateItem(derivedStats, inventory);
	}

	public void visitTrap(TrapItem item){
		if(item.activateItem(occupation, derivedStats))
		{
			RunGame.println("A Trap Has Been Successful Removed!");
			map.remove(desiredLocation);
		}
	}
}
